package com.yhd.controller;

import com.github.pagehelper.Page;
import com.yhd.MenuService;

import com.yhd.model.dto.WebResultDto;
import com.yhd.entity.Menu;
import com.yhd.model.PageInfo;

import com.yhd.model.ResultPage;
import com.yhd.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;



@Slf4j
@RequestMapping
public class MenuController extends WebBaseController {

    @Autowired
    private MenuService menuService;

    @GetMapping("/index")
    public String toIndex(){
        return "/menu/index";
    }

    @GetMapping("/queryList")
    @ResponseBody
    public WebResultDto queryList(HttpServletRequest request, PageInfo pageInfo){
        Page<Menu> page=menuService.selectByPage(null,pageInfo);
        ResultPage<Menu> resultPage= BaseService.pageTransform(page);
        return success( resultPage.getData());

    }


}
